<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>用户组成员</title>
	<script type="text/javascript">
	<!--
	var userTable;
	$(function(){
		userTable = $("#userTable").dataTable({
			"bPaginate":true
			,"oLanguage":{
				"sLengthMenu": "每页显示 _MENU_ 条记录",
				"sZeroRecords": "抱歉， 没有找到",
				"sInfo": "从 _START_ 到 _END_ /共 _TOTAL_ 条数据",
				"sInfoEmpty": "没有数据",
				"sInfoFiltered": "(从 _MAX_ 条数据中检索)",
				"oPaginate": {
					"sFirst": "首页",
					"sPrevious": "前一页",
					"sNext": "后一页",
					"sLast": "尾页"
				},
				"sZeroRecords": "没有检索到数据"
				,"sSearch": "查找:"
				,"sProcessing": "<img src='${pageContext.request.contextPath}/img/loading.gif' />"
			}
			,"bDestroy":true
			,"bServerSide":true
			,"sAjaxSource":"${pageContext.request.contextPath}/sysuser/getSysUserByGroup.do"
			,"sServerMethod": "POST"
			,"fnServerParams":function(aoData){
				aoData.push({"name": "groupId", "value": "${groupId}"});
			}
			,"fnServerData": function(sSource,aoData,fnCallback){
				//aoData.push({name:"groupId",value:"${groupId}"});
				//console.info($.param(aoData));
				$.post(sSource,aoData,function(data){
					if(true == data.isSuccess){
						fnCallback(data.returnObject);
					}else{
						$("#logTable tbody").html("未找到数据");
					}
				},"json");
			}
			,"bJQueryUI": true,
			"sPaginationType": "full_numbers",
			"sDom": '<""l>t<"F"fp>'
			,"aoColumns":[
            	{"sClass":"center","mDataProp":"sysUser.userName"}
            	,{"sClass":"center","mDataProp":"sysUser.loginName"}
            	,{"sClass":"center","mDataProp":"sysUser.email"}
            	,{"sClass":"center","mDataProp":"isLeaderStr"}
            	,{"sClass":"center","mDataProp":"sysUser.userId","fnRender":function(obj){
            		return "<div class=\"btn-group\"><a class=\"btn btn-mini\" href=\"javascript: setLeader('${groupId}','"+obj.aData.sysUser.userId+"')\" \">负责人</a></div>";
            	}}
            	/* ,{"sClass":"center","mDataProp":"logId","bSearchable":false,"bStorable":false,"fnRender":function(obj){
            		return "<a class=\"btn btn-mini\">"+obj.aData.logId+"负责人</a>";
            	}} */
			]
		});
		$('select').select2();
	});
	
	function setLeader(groupId, userId){
		$.post("${pageContext.request.contextPath}/sysuser/updateLeader.do",{"groupId":groupId,"userId":userId},function(data){
			if(true == data.isSuccess){
				if(userTable)
					userTable.fnDraw();
				$("#tmpl_alert").tmpl({type:"success", title:"成功",message:data.returnObject}).appendTo("#message_alert");
			}else{
				$("#tmpl_alert").tmpl({type:"error",title:"失败",message:data.errorMsg}).appendTo("#message_alert");
			}
		},"json");
	}
	//-->
	</script>
</head>
<body>
	<div class="container-fluid">
    <hr>
    <div class="row-fluid">
      <div class="span12"><a href="${pageContext.request.contextPath }/sysuser/querySysUserGroupPage.do" class="btn btn-primary">返回</a></div>
    </div>
    <div class="row-fluid">
      <div class="span12">
      	<div class="widget-box">
          <div class="widget-title"> <span class="icon"><i class="icon-th"></i></span>
            <h5>用户组成员</h5>
          </div>
          <div class="widget-content nopadding">
            <table id="userTable" class="table table-bordered data-table">
              <thead>
                <tr>
                  <th>用户名</th>
                  <th>登录名</th>
                  <th>电子邮箱</th>
                  <th>负责人</th>
                  <th>操作</th>
                </tr>
              </thead>
              <tbody>
              </tbody>
            </table>
          </div>
        </div>
      </div>
    </div>
    </div>
</body>
</html>